/**
 * 时间对象的格式化
 * @param format yyyy-MM-dd HH:mm:ss
 */
Date.prototype.format = function(format) {

    const o = {
        "M+": this.getMonth() + 1, 		// month
        "d+": this.getDate(), 		// day
        "h+": this.getHours(), 		// hour
        "m+": this.getMinutes(), 		// minute
        "s+": this.getSeconds(), 		// second
        "q+": Math.floor((this.getMonth() + 3) / 3), 	// quarter
        "S": this.getMilliseconds()  	// millisecond
    };

    if (/(y+)/.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + "")
            .substr(4 - RegExp.$1.length));
    }

    for (const k in o) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k]
                : ("00" + o[k]).substr(("" + o[k]).length));
        }
    }
    return format;
};
function goTop(){
    //首先将#back-to-top隐藏
    var $goTop = $(".go-to-top");
    $goTop.hide();

    $(window).scroll(function(e) {
        if($(window).scrollTop()>100)
            $goTop.fadeIn(350).css("display","block");
        else
            $goTop.fadeOut(350).css("display","none");
    });

    $goTop.click(function(e) {
        $('body,html').animate({scrollTop:0},500);
        return false;
    });
}


$(document).ready(function() {


    $("img.captcha").click(function(){
        var timenow = new Date().getTime();
        this.src=$(this).attr("src")+"?d="+ timenow;;
    });


    //返回顶部等滑块hover事件
    $('.slider-chat,.slider-qq,.slider-phone,.slider-wechat','#clan-slider').hover(
        function(){
            $(this).next().show();
        },
        function(){
            $(this).next().hide();
        }
    );

    //返回顶部
    goTop();

    //内容加载后的运动效果
    dataAnimate();

    //移动端 JS
    /*var isMobile = device.mobile(),
     isTable  = device.tablet(),
     isiPhone = device.iphone(),
     isiPad   = device.ipad();
     if(isMobile || isTable || isiPhone || isiPad){
     //移除新窗口打开
     $('a').not('[data-mobile-target="_blank"]').removeAttr('target');
     }*/

});